"""
@Author  : 康帅
@Time    : 2021/1/5 10:38
@Function: 考虑用生成器来改写直接返回列表的函数
"""


def index_words(text):
    result = []
    if text:
        result.append(0)
    for index, letter in enumerate(text):
        if letter == ' ':
            result.append(index + 1)
    return result


if __name__ == '__main__':
    address = 'Four score and sevrn years ago...'
    result = index_words(address)
    print(result[:3])

